import { http } from "@/utils"
import type { ResType } from './common'
// 2. 定义具体的接口类型
export type itemList = {
  name: string,
  id: number
}

type ChannelRes = {
  channels: itemList[]
}

// 请求方法
// 请求的数据类型
// {
//   data: {
//     channels: [{ id: 1, name: 'string' }]
//   },
//   message: string
// }
const getInfo = async () => {
  http.request<ResType<ChannelRes>>({
    url: '/channels'
  })
}

export { getInfo }

// 第二个接口
type ListItem = {
  art_id: string,
  title: string,
  count: number,
  pubdate: number,
  cover: {
    type: number,
    images: string[]
  }
}

export type ListRes = {
  reslutes: ListItem[],
  pre_timestamp: string
}
// <ResType<ListRes>> 数据格式 父级包裹子级

type ReqParams = {
  channel_id:number,
  timestamp: string
}
export function fetchList(params:ReqParams) {
  return http.request<ResType<ListRes>>({
    url: '/articles',
    params
  })
}